package com.lx.idgenerator.exception;

import com.lx.idgenerator.model.StateCode;

/**
 * @author lX
 * @version JDK 8
 * @className RedisOperationFailException (此处以class为例)
 * @date 2024/11/9
 * @description TODO
 */
public class RedisOperationFailException extends RuntimeException{

    private String msg;

    private int code;

    public RedisOperationFailException(StateCode stateCode, Throwable throwable) {
        super(throwable);
        this.msg = stateCode.msg();
        this.code = stateCode.code();
    }

    public RedisOperationFailException(String msg, Throwable throwable) {
        super(throwable);
        this.msg = msg;
        this.code = StateCode.REDIS_OPERATION_FAIL.code();
    }

    public RedisOperationFailException(String msg) {
        this.msg = msg;
        this.code = StateCode.ERROR.code();
    }
    public RedisOperationFailException() {
        this.msg = StateCode.REDIS_OPERATION_FAIL.msg();
        this.code = StateCode.REDIS_OPERATION_FAIL.code();
    }

    public RedisOperationFailException(StateCode stateCode) {
        this(stateCode, null);
    }
}
